package com.hz.house.controller.detail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hz.house.bean.vo.BuildingCommentCommand;
import com.hz.house.bean.vo.BuildingCommentReplyCommand;
import com.hz.house.service.detail.BuildingDetailService;
import com.hz.house.token.CurrentUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 楼盘详情页的数据查询.只是查询接口
 * @author lfw
 */
@Api("楼盘详情相关接口")
@RestController
@RequestMapping("/api/v2/detail")
public class BuildingDetailController {
	
	@Autowired
	private BuildingDetailService bdetailService;
	
	@ApiOperation(value = "获取楼盘详情的基本信息")
	@GetMapping("/getBasic")
	public Object getBuildBasicInfo(Integer buildingId) {
		return this.bdetailService.getBuildingBasicInfo(buildingId);
	}

	@ApiOperation(value = "获取楼盘本次开盘和历史开盘信息、剩余房源信息")
	@GetMapping("/getKaiPanInfo")
	public Object getKaiPanInfo(Integer buildingId) {
		return this.bdetailService.getKaiPanInfo(buildingId);
	}
	
	
	@ApiOperation(value = "获取楼盘前三条评论和回复，以及置业顾问和其他栏目数据")
	@GetMapping("/getOthersV2_1")
	public Object getCommentsAndOthersInfoV2_1(Integer buildingId) {
		return this.bdetailService.getCommentsAndOthersInfoV2_1(buildingId);
	}
	
	@ApiOperation(value = "获取楼盘前三条评论和回复，以及置业顾问和其他栏目数据 V2_2")
	@GetMapping("/getOthersV2_2")
	public Object getCommentsAndOthersInfoV2_2(Integer buildingId) {
		return this.bdetailService.getCommentsAndOthersInfoV2_2(buildingId);
	}

	@ApiOperation(value = "获取楼盘二维码分享图")
	@GetMapping("/getBdQrcode")
	public Object getBuildingQRcode(Integer buildingId,String pageUrl){
		return this.bdetailService.getBuildingQRcode(buildingId, pageUrl);
	}
	
	/**
	 * 获取楼盘分类图片
	 * @return
	 */
	@ApiOperation(value = "获取楼盘分类的图片二级页面数据")
	@GetMapping("/getImgs")
	public Object getBuildingImgs(Integer buildingId,String type) {
		return this.bdetailService.getBuildingImgs(buildingId,type);
	}
	
	@ApiOperation(value = "查询户型图子页面数据，返回各类型户型的总数量和户型图,type=all查全部，type=current查询当前开盘")
	@GetMapping("/getHouseModel")
	public Object getHouseModel(Integer buildingId,String type) {
		return this.bdetailService.getHouseModel(buildingId,type);
	}
	
	
	@ApiOperation(value = "查询户型图子页面数据，返回各类型户型的总数量和户型图,type=all查全部，type=current查询当前开盘")
	@GetMapping("/getHouseModelV_2_2")
	public Object getHouseModelV2_2(Integer buildingId,String type) {
		return this.bdetailService.getHouseModelV2_2(buildingId,type);
	}
	
	@ApiOperation(value = "一房一价获取楼栋和装修的装修条件")
	@GetMapping("/getFilters")
	public Object getBuildingAndDecorate(String orderNum) {
		return this.bdetailService.getBuildingAndDecorate(orderNum);
	}
	
	@ApiOperation(value = "分页查询一房一价数据：orderNum预售证号,page分页，"
			+ "orderBy【1-7】数值,canSale[可售1默认0],num【楼栋名称,条件接口返回的值】")
	@GetMapping("/searchHousePrice")
	public Object searchHousePrice(String orderNum,Integer page,Integer orderBy,Integer canSale,String num) {
		return this.bdetailService.searchHousePrice(orderNum, page, orderBy, canSale,num);
	}
	
	@ApiOperation(value = "查询一房一价页面的楼盘基本信息orderId=预售证号")
	@GetMapping("/getProjectInfo")
	public Object getProjectInfo(String orderId) {
		return this.bdetailService.getProjectInfo(orderId);
	}
	
	@ApiOperation(value = "查询历史开盘，一次返回所有")
	@GetMapping("/getHistoryKaiPan")
	public Object getHistoryKaiPan(Integer buildingId) {
		return this.bdetailService.getHistoryKaiPan(buildingId);
	}
	
	@ApiOperation(value = "查询楼盘的全部评论，分页")
	@GetMapping("/getAllComments")
	public Object getAllComments(Integer buildingId,Integer page) {
		return this.bdetailService.getAllComments(buildingId, page);
	}
	
	@ApiOperation(value = "添加楼盘评论")
	@PostMapping("/addComment")
	public Object addComment(@RequestBody BuildingCommentCommand comment) {
		return this.bdetailService.AddComments(comment);
	}
	
	@ApiOperation(value = "回复楼盘下的评论或回复:比以前多加了个参数，楼盘id")
	@PostMapping("/commentReply")
	public Object commentReply(@RequestBody BuildingCommentReplyCommand reply) {
		return this.bdetailService.commentReply(reply);
	}
	
	@ApiOperation(value = "给楼盘详情里的评论点赞iHasPraise=0或1 1是我已经点了赞，0是还没有")
	@GetMapping("/commentPraise")
	public Object praiseComment(Integer commentId,Integer iHasPraise) {
		return this.bdetailService.praiseComment(commentId, iHasPraise);
	}
	
	@ApiOperation(value = "楼盘消息提醒关注,isNotify=false新增提醒，isNotify=true,取消提醒")
	@GetMapping("/notifyMe")
	public Object notifyBuildingMsg(Boolean isNotify,Integer buildingId) {
		return this.bdetailService.notifyBuildingMsg(isNotify, buildingId,CurrentUser.getCurrentUserId());
	}

	@ApiOperation("获取楼盘动态")
	@GetMapping("/getBuildingDyn")
	public Object getBuildingDyn(@RequestParam Integer buildingId,Integer page,Integer size) {
		return bdetailService.getBuildingDyn(buildingId,page,size);
	}

	@ApiOperation("生成楼盘详情海报")
	@GetMapping("/createBuildingDetailBillBase64")
	public Object createBuildingDetailBillBase64(@RequestParam Integer buildingId) {
		return bdetailService.createBuildingDetailBillBase64(buildingId);
	}

	@ApiOperation("获取对应楼盘优惠列表")
	@GetMapping("/getDiscounts")
	public Object getDiscounts(@RequestParam Integer buildingId,Integer page) {
		return bdetailService.getDiscounts(buildingId,page);
	}
}
